package match;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class RegTest
{
    public static void main(String[] args)
    {
        
        
        String s="<p id=km>&nbsp;<a href=http://hi.baidu.com>文本</a>&nbsp;|&nbsp;<a ";
        String regex="<a.*?/a>";        
        //String regex = "<a.*>(.*)</a>";
        Pattern pt=Pattern.compile(regex);
        Matcher mt=pt.matcher(s);
        while(mt.find())
        {
            System.out.println(mt.group());
             String s2=">.*?</a>";
              
              Pattern pt2=Pattern.compile(s2);
              Matcher mt2=pt2.matcher(mt.group());
               while(mt2.find())
                    {
            	      System.out.println(mt2.group());
            	    //ʵ���ϣ�ֻ��ִ����find()���� ��״̬��matcher��������ʼ����ƥ�乤���ģ�
            	      
            	      String s3=">.*?<";
            	      Pattern pt3=Pattern.compile(s3);
            	      Matcher mt3=pt3.matcher(mt2.group());
            	      while(mt3.find())//ʵ���ϣ�ֻ��ִ����find()���� ��״̬��matcher��������ʼ����ƥ�乤���ģ�
            	      {
            	    	  System.out.println(mt3.group());
            	      }
            	     
                      
                      
                    }
        }
    }
}
